home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / st80_pr4.lha / st80_pre4 / WindowMaker / WMExtras.pp.1 < prev    next >
Text File  |  1993-07-24  |  3KB  |  73 lines

  1. "Copyright WilfLalonde, The Object People"!
  2.  
  3. Smalltalk garbageCollect!
  4.  
  5. !DisplayObject methodsFor: 'screen'!
  6. slideFrom: startPoint to: stopPoint steps: steps
  7.     "Displays at all points except the first."
  8.     | i point delta |
  9.     i _ 0. point _ startPoint. delta _ (stopPoint - startPoint) // steps.
  10.     ^self follow: [point _ point + delta] while: [(i _ i+1) < steps]! !
  11.  
  12. !Collection methodsFor: 'private'!
  13. maxPrint
  14.     "Answer the maximum number of characters to print with printOn:."
  15.  
  16.     ^10000! !
  17.     
  18.  
  19. !MethodNode methodsFor: 'code generation'!
  20.  
  21. generateAt: aRemoteString
  22.     "MODIFIED by replacing 4 occurrences of 'self error: ...' by 'encoder notify: ...'."
  23.     "I am the root of a parse tree; answer with an instance of CompiledMethod."
  24.     | blkSize method nLits stack strm nArgs primn |
  25.     self generateIfQuick: 
  26.         [:meth | 
  27.         meth setSourcePosition: aRemoteString.
  28.         meth cacheTempNames: self tempNames.
  29.         ^meth].
  30.     nArgs _ arguments size.
  31.     blkSize _ block sizeForEvaluatedValue: encoder.
  32.     primn _ (primitive < 256) & (primitive > -256) ifTrue: [primitive] ifFalse: [0].
  33.     literals _ encoder literals: primn nArgs: nArgs.
  34.     encoder maxTemp > 31
  35.         ifTrue: [^encoder notify: 'Too many temporary variables'].    
  36.     (nLits _ literals size) > 255
  37.         ifTrue: [^encoder notify: 'Too many literals referenced'].
  38.     method _ CompiledMethod    "Dummy to allocate right size"
  39.                 newBytes: blkSize + CompiledMethod bytesForSource
  40.                 flags: ((nArgs <= 4 and: [primn = 0]) ifTrue: [nArgs] ifFalse: [7])
  41.                 nTemps: encoder maxTemp
  42.                 nStack: 0
  43.                 nLits: nLits.
  44.     strm _ ReadWriteStream with: method.
  45.     strm position: method initialPC - 1.
  46.     stack _ ParseStack new init.
  47.     block emitForEvaluatedValue: stack on: strm.
  48.     stack position ~= 1 ifTrue: [^encoder notify: 'Compiler stack discrepancy'].
  49.     strm position ~= (method size - CompiledMethod bytesForSource)
  50.         ifTrue: [^encoder notify: 'Compiler code size discrepancy'].
  51.     1 to: nLits do: [:lit | method literalAt: lit put: (literals at: lit)].
  52.     method needsStack: stack size encoder: encoder.
  53.     method setSourcePosition: aRemoteString..
  54.     method cacheTempNames: self tempNames.
  55.     ^method! !
  56.     
  57.     
  58.  
  59. !Parser methodsFor: 'public access'!
  60.  
  61. parse: sourceStream class: class noPattern: noPattern context: ctxt
  62.     notifying: req ifFail: aBlock
  63.     "MODIFIED not to destroy the requestor or fail block."
  64.      "Answer with a parse tree.  noPattern is true for doIts (Compiler evaluate)"
  65.  
  66.      | meth |
  67.     self init: sourceStream notifying: req failBlock: [^aBlock value].
  68.     encoder _ Encoder new init: class context: ctxt notifying: self.
  69.     failBlock_ aBlock.
  70.     meth _ self method: noPattern context: ctxt.
  71.     encoder _ "failBlock _ requestor _" parseNode _ nil. "break cycles & mitigate refct overflow"
  72.     ^meth! !
  73.